@extends('home.personal.userlayout')
@section('title','激活账户')
@section('style')
    <link rel="stylesheet" href="{{ asset('/home/css/tixian.css')}}?version=3"/>
@endsection
@section('content')
    <form action="" id="form" method="post" >
        {{ csrf_field() }}
        <div class="l1">
            <input type="text" name="code" value="" placeholder="填写激活码">
        </div>
        <button type="button" class="submit">立即激活</button>
    </form>

@endsection

@section('script')
    <script>
        $('.submit').click(function () {
            var code =  $('input[name=code]').val();
            if(code == ''){
                alert('请填写激活码');
                return false;
            }
            $.ajax({
                //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "/jihuo_post" ,//url
                data: $('#form').serialize(),
                success: function (result) {
                    console.log(result);//打印服务端返回的数据(调试用)
                    alert(result.message);
                    if (result.code == 0) {
                        window.location.href = "{{ url('personal') }}"
                    }
                },
                error : function() {
                    alert("异常！");
                }
            });
        })


    </script>

@endsection